<template>
  <div>
    <NavBar :title="title" />
    <div class="content-top">
      <!-- 提问 -->
      <div class="jobreport-edit">
        <div class="jobreport-firm">
          <span>{{ jobname }}</span>
        </div>
        <van-field
          v-model="postData.content"
          rows="10"
          autosize
          type="textarea"
          placeholder="请简要描述你的问题，以便于我们核实"
          show-word-limit
          maxlength="200"
          style="
            border-radius: 10px;
            margin-bottom: 20px;
            font-size: 16px;
            color: #333;
            line-height: 22px;
          "
        />
        <van-button
          type="primary"
          block
          :loading="loading_submit"
          :disabled="disabled_submit"
          color="#f70"
          round
          style="font-size: 18px"
          text="提交"
          @click="onSubmit"
        ></van-button>
      </div>
    </div>
  </div>
</template>

<script>
import NavBar from "@/components/NavBar.vue";
import { Button, Field, Toast } from "vant";
import { PersonLoginedReportJob } from "@/util/http";
import Global from "@/Global";

export default {
  name: "JobReport",
  components: {
    NavBar,
    [Button.name]: Button,
    [Field.name]: Field,
  },
  props: ["title", "jobid", "jobname"],
  mounted() {
    this.postData.jobid = this.jobid;
    this.postData.jobname = this.jobname;
  },
  // 定义属性
  data() {
    return {
      postData: {
        content: "",
        jobid: "",
        jobname: "",
      },
      loading_submit: false,
    };
  },
  computed: {
    disabled_submit() {
      if (this.postData.content != "") return false;
      return true;
    },
  },
  // 方法集合
  methods: {
    onSubmit() {
      // this.loading_submit = true;
      // PersonLoginedReportJob(this.postData).then((res) => {
      //   this.loading_submit = false;
      //   Toast(res.msg);
      //   if (res.result === 1) {
      //     setTimeout(() => {
      //       this.$router.go(-1);
      //     }, Global.setTimeout_time);
      //   }
      // });
      this.loading_submit = true;
      let data = {
        jobID : this.postData.jobid,
        jobName:this.postData.jobname,
        content:this.postData.content
      }
      this.$api.post('/PersonStation/JobReport',data).then(res=>{
        this.loading_submit = false;
        Toast(res.msg);
        if(res.success){
          this.$router.go(-1);
        }
      })
    },
  },
};
</script>

<style scoped>
.jobreport-edit {
  padding: 10px 15px;
}

.jobreport-edit .jobreport-firm {
  display: flex;
  padding: 10px 15px;
  border-radius: 10px;
  margin-bottom: 10px;
  background-color: #fff;
  font-size: 16px;
  font-weight: 500;
  color: #333;
}

.jobreport-edit .jobreport-firm::before {
  content: "举报：";
  display: flex;
  flex: 0 0 50px;
  color: #f70;
}
</style>
